﻿package {
             import flash.display.MovieClip;
              import flash.events.Event;
            import flash.net.URLLoader;
              import flash.net.URLRequest;
              import flash.media.Sound;
             import flash.media.SoundChannel;
             import flash.system.System;
               import flash.text.TextField;
              import readlrc;
			  
               public class mp3 extends MovieClip {
                         private var lrcreq:URLRequest=new URLRequest("quanshui.lrc");
                          private var mp3url:URLRequest=new URLRequest("quanshui.mp3");
                           private var mymp3:Sound=new Sound();
                           private var channel:SoundChannel=new SoundChannel();
                          private var lrcurl:URLLoader=new URLLoader();
                           private var tbgc:String;
                          private var mylrc:readlrc=new readlrc();
                         System.useCodePage=true;
                         public function mp3() {
                                  mymp3.load(mp3url);
                                  channel=mymp3.play();
                                  lrcurl.load(lrcreq);
                                    lrcurl.addEventListener(Event.COMPLETE,loaded);
                            }
                           private function enterframe(event:Event) {
                                     try {
                                             gc_txt.text=mylrc.readlrcastime(int(channel.position/1000),tbgc);
                                      } catch (error:Error) {
                                             //
                                       }


                             }
                              private function loaded(event:Event) {
                                            tbgc=String(event.target.data);
                                            addEventListener(Event.ENTER_FRAME,enterframe);
                                                }
                  }
}